list1 = [54, 26, 93, 17, 77, 31, 44, 55, 20]

# list1 = [54, 26, 20, 17, 77, 31, 44, 55, 93]
# list1 = [54, 26, 20, 17, 55, 31, 44, 77, 93]

# n --> len(list1)

# # 第一圈操作
# max_num_index = 0
# for i in range(len(list1)):
#     if list1[max_num_index] < list1[i]:
#         max_num_index = i
# list1[len(list1) - 1], list1[max_num_index] = list1[max_num_index], list1[len(list1) - 1]
# # [54, 26, 20, 17, 77, 31, 44, 55, 93]
#
# # 第二圈操作
# max_num_index = 0
# for i in range(len(list1) - 1):
#     if list1[max_num_index] < list1[i]:
#         max_num_index = i
# list1[len(list1) - 2], list1[max_num_index] = list1[max_num_index], list1[len(list1) - 2]


# 第n-1圈 操作   排n或者n-1圈
# for n in range(len(list1)-1):
for n in range(len(list1)):
    max_num_index = 0
    for i in range(len(list1) - n):
        if list1[max_num_index] < list1[i]:
            max_num_index = i
    list1[len(list1) - n - 1], list1[max_num_index] = list1[max_num_index], list1[len(list1) - n - 1]

print(max_num_index)
print(list1)
